<?php
    require('./Utils.php');

    $post = getJsonParamter();

    $username = $post['username'];
    $password = $post['password'];

    $conn = getConnection();
    $sql = "SELECT username, avatar FROM user WHERE username = ? AND password = ?";

    $data = query($conn, $sql, $username, $password);

    $username = $data['username'];
    
    if($username) getJson(200, '登录成功', $data);
    
    else getJson(500, '登陆失败，账号或密码错误', null);
        
?>